import jwt

class JWTE:
    def __init__(self):
        self.secrite_key = 'a5d4w651a2s.da6w54d'
    # 加密 
    def jwt_en(self,data):
        return str(jwt.encode(data,self.secrite_key,algorithm='HS256'),
        encoding='utf8')

    # 解密
    def jwt_decode(self,token):
            try:
                data = jwt.decode(token,self.SECRET_KEY,algorithm='HS256') 
                #重新加密获取新的token
                newtoken = jwt.encode(data,self.SECRET_KEY,algorithm='HS256') 
                return str(newtoken,encoding='utf8')
            except:
                return None
        #对比
    def check(self,token,newtoken):
        if token == newtoken:
            return True
        return False
# import time
myjwt = JWTE()